package cn.edu.cqytxy.controller;

import cn.edu.cqytxy.controller.req.LoginReq;
import cn.edu.cqytxy.service.AuthService;
import cn.edu.cqytxy.service.impl.AuthServicePhoneCodeImpl;
import cn.edu.cqytxy.service.impl.AuthServiceUsernamePasswordImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author yinjw
 */
public class LoginServlet extends HttpServlet {


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        // 手机号验证码登录
        // AuthService authService = new AuthServicePhoneCodeImpl();

        // 帐号密码登录
        // AuthService authService = new AuthServiceUsernamePasswordImpl();

        // 局部内部类
        AuthService authService = new AuthService() {
            @Override
            public void login(LoginReq req) {
                System.out.println("2");
                System.out.println("1");
            }
        };
//        AuthService authService = req -> {
//            System.out.println("2");
//            System.out.println("1");
//        };

        authService.login(null);
    }
}
